﻿<script>
    //打印

    $('report').addEvent('click', function () {
        var begin_date = $('paybegin_date').get('value');
        var begin_date_objh = document.getElementsByName("_DTIME_[H][paybegin_date]")[0];
        var begin_date_h = begin_date_objh.options[begin_date_objh.selectedIndex].value;
        var begin_date_objm = document.getElementsByName("_DTIME_[M][paybegin_date]")[0];
        var begin_date_m = begin_date_objm.options[begin_date_objm.selectedIndex].value;
        begin_date = begin_date + " " + begin_date_h + ":" + begin_date_m;
        begin_date = new Date(begin_date).getTime();

        var end_date = $('payend_date').get('value');
        var payend_date_objh = document.getElementsByName("_DTIME_[H][payend_date]")[0];
        var end_date_h = payend_date_objh.options[payend_date_objh.selectedIndex].value;
        var payend_date_objm = document.getElementsByName("_DTIME_[M][payend_date]")[0];
        var end_date_m = payend_date_objm.options[payend_date_objm.selectedIndex].value;
        end_date = end_date + " " + end_date_h + ":" + end_date_m;
        end_date = new Date(end_date).getTime();

        var shop_id = $('shop').get('value');
        var customer_name=$('customer').get('value');
        var data_type = $('conditiondate').get('value');
        var url = "index.php?app=omeanalysts&ctl=analysis_lmreport&act=report";
        url += '&conditiondate=' + data_type + '&shop=' + shop_id + '&paybegin_date=' + begin_date + '&payend_date=' + end_date+'&customer_name='+customer_name;
        window.open(url);
    });

</script>
<div class="tableform">
    <h3>订单跟踪汇总表</h3>

    <form id="Searchform" action="index.php?app=omeanalysts&ctl=analysis_lmreport&act=index" method="post">
        <div class="division">
            <table width='100%' cellspacing="0" cellpadding="0">
                <tr>
                    <td>
                        店铺：
                        <select name="shop" id="shop">
                            <option value="">全部</option>
                            <{foreach from=$shop key=key item=val}>
                            <option value="<{$val.shop_id}>"
                            <{if $val.shop_id==$clearingtable.shop_id}>selected<{/if}> ><{$val.name}></option>
                            <{/foreach}>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        客户：
                        <select name="customer_name" id="customer">
                            <option value="">全部</option>
                            <{foreach from=$customerList key=key item=val}>
                            <option value="<{$val.customername}>" <{if $val.customername ==$clearingtable.customer_name }>selected<{/if}>  >
                            <{$val.customername}>
                            </option>
                            <{/foreach}>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <select name="conditiondate" id="conditiondate">
                            <{foreach from=$conditiondate key=key item=val}>
                            <option value="<{$val.id}>"
                            <{if $val.id==$clearingtable.conditiondate_id}>selected<{/if}> ><{$val.name}></option>
                            <{/foreach}>
                        </select><{input type="time" name="paybegin_date" vtype="required" id="paybegin_date"
                        value="{$clearingtable.paybegin_date}" }>
                        至：<{input type="time" value="{$clearingtable.payend_date}" id="payend_date" name="payend_date"}>
                        <{button class="btn btn-primary" type="submit" id="saveCurrent" label="查询"}>

                        <{button class="btn btn-primary" type="button" id="report" label="导出"}>
                    </td>
                </tr>
            </table>
        </div>
    </form>

    <div class="division" id="accordion" style="width:1200px;">

        <table width="1000px" cellspacing="0" cellpadding="0" class="gridlist">
            <thead>
            <tr>
                <th style="width:200px;">店铺</th>
                <th style="width:100px;">货号</th>
                <th style="width:200px;">货品名称</th>
                <th style="width:50px;">单位</th>
                <th style="width:100px;">订单量</th>
                <th style="width:60px;">备货量</th>
                <th style="width:60px;">打印面单量</th>
                <th style="width:60px;">发货量</th>
                <th style="width:60px;">未发量</th>
                <th style="width:60px;">退款量</th>
            </tr>
            </thead>

            <{assign var="key1" value="0"}>
            <{assign var="key2" value="0"}>
            <{assign var="print" value="0"}>
            <{assign var="key3" value="0"}>
            <{assign var="key4" value="0"}>
            <{assign var="key5" value="0"}>
            <{foreach from=$comp_data item=his}>
            <{assign var="key1" value=$key1+$his.qty }>
            <{assign var="key2" value=$key2+$his.qty1 }>
            <{assign var="print" value=$print+$his.print_nums }>
            <{assign var="key3" value=$key3+$his.qty2 }>
            <{assign var="key4" value=$key4+$his.qty3 }>
            <{assign var="key5" value=$key5+$his.qty4 }>
            <tbody>
            <tr>
                <td><{$his.shop_name}></td>
                <td><{$his.material_bn}></td>
                <td><{$his.material_name}></td>
                <td><{$his.unit}></td>
                <td><{$his.qty}></td>
                <td><{$his.qty1}></td>
                <td><{$his.print_nums}></td>
                <td><{$his.qty2}></td>
                <td><{$his.qty3}></td>
                <td><{$his.qty4}></td>
            </tr>
            </tbody>
            <{/foreach}>
            <tr>
                <td colspan="4"><b style="font-size:12px;color:red;">总数：</b></td>
                <td><b style="font-size:12px;color:red;"><{$key1}></b></td>
                <td><b style="font-size:12px;color:red;"><{$key2}></b></td>
                <td><b style="font-size:12px;color:red;"><{$print}></b></td>
                <td><b style="font-size:12px;color:red;"><{$key3}></b></td>
                <td><b style="font-size:12px;color:red;"><{$key4}></b></td>
                <td><b style="font-size:12px;color:red;"><{$key5}></b></td>
            </tr>
        </table>
    </div>

    <div class="division">
    </div>
</div>
